<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="javabean.Conn" %>
    <%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>register_deal</title>
</head>
<body>

<jsp:useBean id="user" class="javabean.User"></jsp:useBean>
<jsp:setProperty property="*" name="user"/>
<%
try{
Connection conn=Conn.connect();
String selectsql="select * from wuqiantong where name=?";
PreparedStatement ps0=conn.prepareStatement(selectsql);
ps0.setString(1,user.getName());
ResultSet rs=ps0.executeQuery();
if(rs.next()){
	out.print("You've registered.Please login.");
}
else{
String insertsql="insert into wuqiantong (name,interest,password) values(?,?,?)";
PreparedStatement ps=conn.prepareStatement(insertsql);
ps.setString(1, user.getName());
ps.setString(2, user.getInterest());
ps.setString(3,user.getPassword());
int row=ps.executeUpdate();
if(row>0){
	out.print("Register successfully!");
}
ps.close();
}
ps0.close();
conn.close();
}
catch(Exception e){
	e.printStackTrace();
	out.print("Register failed.");
}
%>
<a href="register.jsp">back</a>
<a href="login.jsp">login</a>
</body>
</html>